package pos.domain;

import java.util.List;

import pos.data.JDBCRelationDAO;

public class RelationStore {

	@SuppressWarnings("unused")
	private List<Relation> relations;
	private static RelationStore relationsStore;

	public static synchronized RelationStore getInstance() {
		relationsStore = new RelationStore();

		return relationsStore;
	}

	public RelationStore() {
		relations = (new JDBCRelationDAO()).getAllRelations();
	}
	
	public Relation getRelationById (String idRelation){
		return new JDBCRelationDAO().getRelationById(idRelation);
	}
	
	public List<Relation> getListRelationsByEvent (Event event){
		return new JDBCRelationDAO().getListRelationsByEvent(event.getId());
		
	}
	
	public Relation insertRelation (Relation relation, Event event){
		Relation rRes = null;
		rRes = new JDBCRelationDAO().insertRelation(relation, event.getId());
		return rRes;
	}
	
	public boolean existRelation(Relation relation, Event event){
		return new JDBCRelationDAO().existRelation(relation.getSubject(),
				relation.getVerb(),relation.getObject(), event.getId());
	}

}
